package com.vvv.shortlink.project.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.vvv.shortlink.project.dao.entity.LinkDeviceStatsDO;
import com.vvv.shortlink.project.dto.req.LinkStatsReqDTO;
import com.vvv.shortlink.project.dto.resp.LinkStatsDeviceRespDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
* @author Dell
* @description 针对表【t_link_device_stats】的数据库操作Mapper
* @createDate 2024-02-21 16:12:10
* @Entity com.vvv.shortlink.project.dao.entity.LinkDeviceStatsDO
*/
public interface LinkDeviceStatsMapper extends BaseMapper<LinkDeviceStatsDO> {

    /**
     * 记录访问设备监控数据
     */
    @Insert("INSERT INTO t_link_device_stats (full_short_url, user_id, date, cnt, device) " +
            "VALUES( #{linkDeviceStats.fullShortUrl}, #{linkDeviceStats.userId}, #{linkDeviceStats.date}, #{linkDeviceStats.cnt}, #{linkDeviceStats.device}) " +
            "ON DUPLICATE KEY UPDATE cnt = cnt +  #{linkDeviceStats.cnt};")
    void monitorShortLink(@Param("linkDeviceStats") LinkDeviceStatsDO linkDeviceStatsDO);

    /**
     * 以访问设备类型分组，获取范围时间内各访问设备类型的总访问量pv
     *
     * @param requestParam
     * @return
     */
    List<LinkStatsDeviceRespDTO> listDeviceStatsGroupByDevice(@Param("requestParam") LinkStatsReqDTO requestParam);
}




